/*
 *--------------------------------------------------------------------------
 *   File Name:	syscall.h
 * 
 * Description:	none
 * 
 * 
 *      Author:	Zhao Yanbai [zhaoyanbai@126.com]
 * 
 *     Version:	1.0
 * Create Date: Fri Jan  2 19:52:28 2009
 * Last Update: Fri Jan  2 19:52:28 2009
 * 
 *--------------------------------------------------------------------------
 */

#ifndef	_SYSCALL_H
#define	_SYSCALL_H

#include "page.h"

#define	SYSC_NUM	255

typedef	int	SyscReturn;
typedef SyscReturn  (*pfSysc)();


#define	SYSENTER		\
	asm(			\
	"pushl %ecx;"		\
	"pushl %edx;"		\
	"pushl %ebp;"		\
	"pushl $1f;"		\
	"movl %esp,%ebp;"	\
	"sysenter;"		\
	"1:"			\
	"addl $4,%esp;"		\
	"popl %ebp;"		\
	"popl %edx;"		\
	"popl %ecx;");		\



#define	sysenter(vect)({ 	\
	asm(""::"a"(vect));	\
	SYSENTER		\
})

#define	syscall0(vect)({	\
	sysenter(vect);		\
)}

#define	syscall1(vect, a)({	\
	asm(""::"b"(a));	\
	sysenter(vect);		\
})

#define	syscall2(vect, a, b)({	\
	asm(""::"b"(a), "d"(b));\
	sysenter(vect);		\
)}

#define	syscall3(vect, a, b, c)({	\
	asm(""::"b"(a), "d"(b), "c"(c));\
	sysenter(vect);			\
})

#endif //_SYSCALL_H
